﻿
@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<style type="text/css">
    .form .formValue input.form-control {
        height: 32px;
        line-height: 32px;
        padding: 0px;
        resize: none;
        border-radius: 0px;
        box-shadow: none;
        text-indent: 5px
    }

    .textValue {
        width: 100%;
    }

    .selectbox {
        color: #444;
        line-height: 34px;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        height: 34px;
        width: 100%;
    }

    .search {
        margin-left: 10px;
        padding: 0px;
    }

    table td {
        height: 40px;
        line-height: 40px;
    }

    .zdyPanel {
        background-color: #fff;
        border-top: 1px solid #ddd;
        border-left: 1px solid #ddd;
        border-right: 1px solid #ddd;
        margin: 0px;
        float: left;
        width: 100%;
    }

    .zdyTool {
        float: left;
        padding-left: 10px;
        width: 100%;
    }

    .zdyBar {
        padding: 0px;
        margin: 0px;
        margin-top: 3px;
    }

    .zdyUL {
        list-style-type: none;
        margin: 5px 0px 0px -3px;
        padding: 0px;
    }

        .zdyUL li {
            float: left;
            list-style: none;
            height: 24px;
            line-height: 22px;
        }

            .zdyUL li a {
                cursor: pointer;
                padding: 5px 10px;
                border-radius: 4px;
            }

            .zdyUL li i {
                margin-right: 4px;
                font-size: 13px;
                color: #666;
                vertical-align: middle;
                margin-top: -1px;
            }

            .zdyUL li a:hover {
                text-decoration: none;
                background-color: #1ABC9C;
                color: #fff;
            }

    .zdyGirdPanel {
        width: 100%;
        margin: 0px;
        padding: 0px;
        float: left;
    }

    .zdyContentPanel {
        width: 100%;
        margin: 5px 0px 0px 0px;
        padding: 0px;
        float: left;
    }

    .zdyFont {
        padding-left: 5px;
        color: #ff6a00;
    }

    .autocomplete-suggestions {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        border: 1px solid #999;
        background: #FFF;
        cursor: default;
        overflow: auto;
        -webkit-box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
        -moz-box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
        box-shadow: 1px 4px 3px rgba(50, 50, 50, 0.64);
    }

    .autocomplete-selected {
        background: #F0F0F0;
    }

    .autocomplete-suggestion {
        padding: 2px 5px;
        white-space: nowrap;
        overflow: hidden;
    }

    .autocomplete-no-suggestion {
        padding: 2px 5px;
    }

    .zdyUL {
        list-style-type: none;
        margin: 5px 0px 0px -3px;
        padding: 0px;
    }

        .zdyUL li {
            float: left;
            list-style: none;
            height: 24px;
            line-height: 22px;
        }

            .zdyUL li a {
                cursor: pointer;
                padding: 5px 10px;
                border-radius: 4px;
            }

            .zdyUL li i {
                margin-right: 4px;
                font-size: 13px;
                color: #666;
                vertical-align: middle;
                margin-top: -1px;
            }

            .zdyUL li a:hover {
                text-decoration: none;
                background-color: #1ABC9C;
                color: #fff;
            }

    .zdyGirdPanel {
        padding-top: 3px;
    }

    .form .formValue {
        padding: 1px 3px;
    }
</style>
<script>
    var workFlowId = $.request("keyValue");

    $(function () {
        initGridList();
    });

    //初始化列表数据
    function initGridList() {
        var $gridList = $("#gridList");

        $gridList.dataGrid({
            url: "/WorkFlowSetting/FlowManage/GetWorkFlowDetailGridJson",
            postData: { keyValue: workFlowId },
            height: 630,
            colModel: [
                {
                    label: '步骤名称', name: 'F_StepName', width: 100
                },
                {
                    label: '流程序号', name: 'F_WorkFlowNo', width: 50
                },
                {
                    label: '超期提示', name: 'F_TimeOutTip', align: 'left', width: 100
                },
                {
                    label: '指定完成工时（小时）', name: 'F_WorkHours', align: 'left', width: 120
                },
                {
                    label: '超时处理', name: 'F_TimeOutOpreation', align: 'left', width: 80
                },   
                {
                    label: '处理者类型', name: 'F_OperationPersonType', align: 'left', width: 100
                },
                {
                    label: '处理人', name: 'F_OpreationUsers', align: 'left', width: 100
                },
                {
                    label: '处理策略', name: 'F_OpreationStrategy', align: 'left', width: 100
                },
                {
                    label: '退回策略', name: 'F_ReturnStrategy', align: 'left', width: 100
                },
                {
                    label: '退回类型', name: 'F_ReturnType', align: 'left', width: 100
                },
                {
                    label: '处理者类型', name: 'F_CcOperationPType', align: 'left', width: 100
                },
                {
                    label: '抄送人', name: 'F_CcUserId', align: 'left', width: 100
                },
                {
                    label: '通知方式', name: 'F_MessageSend', align: 'left', width: 150
                },
                {
                    label: '是否会签', name: 'F_IsCountersign', align: 'left', width: 100, formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == "0") {
                            return "不会签";
                        } else {
                            return "需要会签";
                        }
                    }
                },
                {
                    label: '处理者类型', name: 'F_CounTersignType', align: 'left', width: 100
                },
                {
                    label: '会签人', name: 'F_ConunTerisnUserId', align: 'left', width: 100
                },
                {
                    label: '操作', name: 'F_WorkFlowDetailId', width: 120, align: 'center',
                    formatter: function (cellvalue, options, rowObject) {
                        return '<div class="btn-group btn-group-xs" style="margin-top:5px;">'
                            + '   <button type="button" class="btn btn-link" onclick="btn_edit(\'' + cellvalue + '\', 0)">编辑</button>'
                            + '   <button type="button" class="btn btn-link" onclick="btn_delete(\'' + cellvalue + '\')">删除</button>'
                            + '</div>';
                    }
                },
                { label: '', name: 'F_WorkFlowDetailId', hidden: true },
                { label: '', name: 'F_WorkFlowId', hidden: true }
            ],
            pager: "#gridPager",
            viewrecords: true,
            multiselect: false,
            sortname: 'F_Id',
            ondblClickRow: function (rowid, iRow, iCol, e) {
                showDetailDialogBox(e);
            }
        });
    }

    //编辑
    function edit(id, title, mark) {
        var opt = {
            id: "editForm",
            title: title,
            url: "/WorkFlowSetting/FlowManage/EditWorkFlowDetail?workFlowId=" + workFlowId + "&keyValue=" + id + '&mark=' + mark,
            width: "1200px",
            height: "700px"
        };

        if (mark == 'detail') {
            $.extend(opt,
                {
                    btn: null
                });
        } else {
            $.extend(opt,
                {
                    callBack: function (iframeId) {
                        top.frames[iframeId].submitForm();
                    }
                });
        }

        $.modalOpen(opt);
    }

    //新增
    function btn_add() {
        edit('', '新建-流程步骤', 'add');
    }

    //编辑
    function btn_edit(id) {
        edit(id, '编辑-流程步骤', 'edit');
    }

    //删除
    function btn_delete(id) {
        $.modalConfirm('确定删除吗？', function (flag) {
            if (flag) {
                $.submitForm({
                    url: "/WorkFlowSetting/FlowManage/DeleteWorkFlowDetail?keyValue=" + id,
                    param: {},
                    success: function (data) {
                        $.currentWindow().$("#gridList").trigger("reloadGrid");
                    }
                });
            }
        });
    }

    //显示详情对话框
    function showDetailDialogBox(e) {
        var rowobj = $(e.currentTarget).jqGridRowValue();

        if (rowobj.F_WorkFlowDetailId) {
            edit(rowobj.F_WorkFlowDetailId, '详情-流程步骤', 'detail');
        } else {
            $.modalAlert("请选中行数据！", "warning");
        }
    }

</script>
<div class="zdyPanel">
    <div class="zdyBar" style="float:right;white-space:nowrap;width:50%;padding-top:5px;">
        <div style="float:right;">
            <div class="btn-group">
                <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
            </div>
            <div class="btn-group">
                <a class="btn btn-primary" onclick="btn_add()"><i class="fa fa-eraser">新建步骤</i></a>
            </div>
        </div>
    </div>
</div>
<div class="zdyGirdPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
